package com.example.backend.controller;

import com.example.backend.entity.Suggestion;
import com.example.backend.model.BaseModel;
import com.example.backend.service.SuggestionService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("suggestion")
public class SuggestionController {

    @Resource
    private SuggestionService suggestionService;

    @Resource
    HttpSession session;

    @Resource
    HttpServletRequest request;

    //添加意见反馈
    @RequestMapping(value = "addSuggestions", method = RequestMethod.POST)
    public BaseModel addSuggestions(){
        int suggestionId = Integer.parseInt(request.getParameter("suggestionId"));
        int userId = Integer.parseInt(request.getParameter("userId"));
        String content = request.getParameter("content");
        String date = request.getParameter("date");
        if(suggestionService.addSuggestions(suggestionId,userId,content,date))
            return new BaseModel(0,"success");
        else
            return new BaseModel(1,"error");
    }
}
